package com.test5;

import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.util.ArrayList;

/**
 * 实现反序列化（读取重构成对象）
 */
public class ObjectInputStreamTest {
    public static void main(String[] args) throws Exception {
        FileInputStream fis = new FileInputStream("C:\\Users\\LDH\\Desktop\\test.txt");
        ObjectInputStream ois = new ObjectInputStream(fis);
        //读取文件
//        Students s = (Students) ois.readObject();
        ArrayList<Students> list = (ArrayList<Students>) ois.readObject();
        //关闭
        ois.close();
        System.out.println("执行完毕");
        System.out.println(list.toString());
    }
}
